using System;
using System.Windows;

namespace CustomPlate
{
	public class Rectangle
	{
		public double Left { get; set; }

		public double Top { get; set; }

		public double Right { get; set; }

		public double Bottom { get; set; }

		public Point LeftTop
		{
			get
			{
				return new Point(Left, Top);
			}
			set
			{
				Left = value.X;
				Top = value.Y;
			}
		}

		public Point RightBottom
		{
			get
			{
				return new Point(Right, Bottom);
			}
			set
			{
				Right = value.X;
				Bottom = value.Y;
			}
		}

		public Rectangle()
		{
		}

		public Rectangle(double left, double top, double right, double bottom)
		{
			Left = left;
			Top = top;
			Right = right;
			Bottom = bottom;
		}

		public bool IntersectsWith(Rectangle rect)
		{
			double num = Math.Min(Left, Right);
			double num2 = Math.Min(Top, Bottom);
			double num3 = Math.Max(Left, Right);
			double num4 = Math.Max(Top, Bottom);
			double left = rect.Left;
			double top = rect.Top;
			double right = rect.Right;
			double bottom = rect.Bottom;
			bool result = false;
			if (num <= left && num2 <= top && num3 >= left && num4 >= top)
			{
				result = true;
			}
			else if (num >= left && num <= right && num2 <= top && num4 >= top)
			{
				result = true;
			}
			else if (num2 >= top && num2 <= bottom && num <= left && num3 >= left)
			{
				result = true;
			}
			else if (num >= left && num <= right && num2 >= top && num2 <= bottom)
			{
				result = true;
			}
			else if (num <= left && num >= right && num2 <= top && num2 >= bottom)
			{
				result = true;
			}
			return result;
		}

		public override string ToString()
		{
			return string.Format("Left:{0}, Top:{1}, Right:{2}, Bottom:{3}", Left, Top, Right, Bottom);
		}
	}
}
